package com.fgr.mapper;

import com.fgr.beans.Adapter;
import com.fgr.beans.Animal;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface AnimalMapper {
//    @Select("select * from an_animal")
    public List<Animal> selectAllAnimal();

//    @Select("select * from an_animal where an_type_id=#{type_id}")
    public List<Animal> selectAnimalByTypeId(Integer type_id);

    //    @Select("select * from an_animal where an_type_id=#{type_id}")
    public List<Animal> selectAnimalByTypeIdAndStat(@Param("type_id") Integer type_id,@Param("anStat") Integer anStat);

    //@Select("select * from an_animal where an_id=#{id}")
    public Animal selectAnimalById(Integer id);

    @Insert("insert into an_animal(an_type_id,an_name,an_age,an_formation,an_picture) values (#{anTypeId},#{anName},#{anAge},#{anFormation},#{anPicture})")
    public Integer insertAdapter(Animal animal);

    @Update("update an_animal set an_type_id=#{anTypeId},an_name=#{anName},an_age=#{anAge},an_formation=#{anFormation} where an_id=#{anId}")
    public Integer updateAnimal(Animal animal);

    @Update("update an_animal set an_stat=1  where an_id=#{anId}")
    public Integer updateAnimalStat(Integer anId);

    @Delete("delete from an_animal where an_id=#{anId}")
    public Integer deleteAdapter(Integer an_id);

    @Delete("delete from an_animal where an_type_id=#{type_id}")
    public Integer deleteAnimalByTypeId(Integer type_id);
}
